library(rjson)
congress <- fromJSON(file = "~/Documents/Mod 3/Unstructured Data Analytics/Homework/Homework 2/BioguideProfiles/congress.json")
filtered_ID <- purrr::map_df(1:length(congress), ~{
data.frame(ID = congress[.x][[1]]$id)}) # get their IDs
congress_df <- purrr::map_df(1:length(congress), ~{
#setwd("~/Documents/Mod 3/Unstructured Data Analytics/Homework/Homework 2/BioguideProfiles/")
read <- fromJSON(file = paste0("~/Documents/Mod 3/Unstructured Data Analytics/Homework/Homework 2/BioguideProfiles/",
filtered_ID[.x,1], ".json"))
data.frame(ID = read$usCongressBioId,
FirstName = read$givenName,
LastName = read$familyName,
Latest_Position = read$jobPositions[length(read$jobPositions)][[1]]$job$name,
Latest_Party = read$jobPositions[length(read$jobPositions)][[1]]$congressAffiliation$partyAffiliation[[1]]$party$name,
Latest_State = read$jobPositions[length(read$jobPositions)][[1]]$congressAffiliation$represents$regionCode,
Profile = read$profileText)
})
str(congress_df)'data.frame': 241 obs. of 7 variables:
$ ID : chr "A000376" "A000375" "A000148" "B001291" ...
$ FirstName : chr "Colin" "Jodey" "Jake" "Brian" ...
$ LastName : chr "Allred" "Arrington" "Auchincloss" "Babin" ...
$ Latest_Position: chr "Representative" "Representative" "Representative" "Representative" ...
$ Latest_Party : chr "Democrat" "Republican" "Democrat" "Republican" ...
$ Latest_State : chr "TX" "TX" "MA" "TX" ...
$ Profile : chr "A Representative from Texas; born in Dallas, Dallas County, Tex., April 15, 1983; graduated from Hillcrest High"| __truncated__ "A Representative from Texas; born in Plainview, Tex., March 9, 1972; graduated from Plainview High School, Plai"| __truncated__ "a Representative from Massachusetts; born in Boston, Suffolk County, Mass., on January 29, 1988; graduated from"| __truncated__ "A Representative from Texas; born in Port Arthur, Jefferson County, Tex., March 23, 1948; graduated from Forest"| __truncated__ ...
head(congress_df) ID FirstName LastName Latest_Position Latest_Party Latest_State
1 A000376 Colin Allred Representative Democrat TX
2 A000375 Jodey Arrington Representative Republican TX
3 A000148 Jake Auchincloss Representative Democrat MA
4 B001291 Brian Babin Representative Republican TX
5 B001307 James Baird Representative Republican IN
6 B001299 James Banks Representative Republican IN
Profile
1 A Representative from Texas; born in Dallas, Dallas County, Tex., April 15, 1983; graduated from Hillcrest High School, Dallas, Tex., 2001; B.A., Baylor University, Waco, Tex., 2005; J.D., University of California, Berkeley, Calif., 2014; professional athlete; nonprofit executive; lawyer; staff, United States Department of Housing and Urban Development, 2016-2017; elected as a Democrat to the One Hundred Sixteenth and to the two succeeding Congresses (January 3, 2019-present).
2 A Representative from Texas; born in Plainview, Tex., March 9, 1972; graduated from Plainview High School, Plainview, Hale County, Tex., 1990; B.A., Texas Tech University, Lubbock, Tex., 1994; M.A., Texas Tech University, Lubbock, Tex., 1997; special assistant to President George W. Bush, 2001; staff, chairman of the Federal Deposit Insurance Corporation, 2001-2005; Deputy Federal Coordinator and Chief Operating Officer, Office of the Federal Coordinator for Gulf Coast Rebuilding, 2005-2006; administrator, Texas Tech University, Lubbock, Tex., 2007-2014; business executive; elected as a Republican to the One Hundred Fifteenth and to the three succeeding Congresses (January 3, 2017-present); chair, Committee on the Budget (One Hundred Eighteenth Congress).
3 a Representative from Massachusetts; born in Boston, Suffolk County, Mass., on January 29, 1988; graduated from Newton North High School, Newton, Mass., 2006; A.B., Harvard University, Cambridge, Mass., 2010; M.B.A., Massachusetts Institute of Technology, Cambridge, Mass., 2016; United States Marine Corps, 2010-2015; member of the Newton, Mass., city council, 2016-2020; business professional; elected as a Democrat to the One Hundred Seventeenth and to the succeeding Congress (January 3, 2021-present).
4 A Representative from Texas; born in Port Arthur, Jefferson County, Tex., March 23, 1948; graduated from Forest Park High School, Beaumont, Tex., 1966; B.S., Lamar University, Beaumont, Tex., 1973; D.D.S., University of Texas, Houston, Tex., 1976; United States Air Force, 1975-1979; Texas Army National Guard, 1969-1975; dentist; alderman, Woodville, Tex., 1981-1982, 1984-1989; Mayor of Woodville, Tex., 1982-1984; member, Texas Historical Commission, 1989-1995; member of the Woodville, Tex., school board, 1992-1995; unsuccessful candidate for election to the One Hundred Fifth Congress in 1996; unsuccessful candidate for election to the One Hundred Sixth Congress in 1998; member, Lower Neches Valley Authority, 1999-2014; elected as a Republican to the One Hundred Fourteenth and to the four succeeding Congresses (January 3, 2015-present).
5 a Representative from Indiana; born in Fountain County, Ind., June 4, 1945; graduated from Turkey Run High School, Marshall, Ind., 1963; B.S., Purdue University, West Lafayette, Ind., 1967; M.S., Purdue University, West Lafayette, Ind., 1969; Ph.D., University of Kentucky, Lexington, Ky., 1975; United States Army, 1969-1972; farmer; small business owner; commissioner, Putnam County, Ind., 2006-2010; member of the Indiana general assembly, 2010-2018; elected as a Republican to the One Hundred Sixteenth and to the two succeeding Congresses (January 3, 2019-present).
6 A Representative from Indiana; born in Columbia City, Whitley County, Ind., July 16, 1979; graduated from Columbia City High School, Columbia City, Ind., 1997; B.A., Indiana University, Bloomington, Ind., 2004; M.B.A., Grace College and Seminary, Winona Lake, Ind., 2013; United States Navy Reserve, 2012-present, Afghanistan War Veteran, 2014-2015; commercial real estate broker; chairman, Whitley County, Ind., Republican Party, 2007-2011; member of the Whitley County, Ind. Council, 2008-2010; member of the Indiana state senate, 2010-2016; elected as a Republican to the One Hundred Fifteenth and to the three succeeding Congresses (January 3, 2017-present).